version 14.1
set more off

***************************************************************************************************
*THIS FILE PRODUCES TABLE A.XIX OF SLEMROD-REHMAN-WASEEM-2020, RESTAT
***************************************************************************************************

/* PRELIMINARIES */

use				"$project_data\ITRM_Dislo_Unique_Top1000_Corporate_Master.dta", clear
#d				;
matrix 			input table=(0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0);
#d				cr

/* DEFINE TREATMENT VARIABLE */

qui				tab year, g(ydum)
g				after=year>=2012
g				treat=(rank>80 & rank<=120)
g				treat_after=treat*after
local			i=1
local			j=1
reg 			logdelT i.year treat treat_after, cluster(regno)
matrix			table[`i',`j']=_b[treat_after]
matrix			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+16,`j']=e(N)
local			j=`j'+1

/* PUBLIC LIMITED COMPANY */

local			i=1
g				trait=public==1
g				treat_after_trait=treat_after*trait
g				trait_after=trait*after
g				trait_treat=trait*treat
reg 			logdelT i.year treat trait treat_after trait_after trait_treat treat_after_trait, cluster(regno)
matrix			table[`i',`j']=_b[treat_after]
matrix			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=_b[treat_after_trait]
matrix			table[`i'+3,`j']=_se[treat_after_trait]
matrix			table[`i'+16,`j']=e(N)
local			j=`j'+1

/* FOREIGN OWNED */

local			i=1
cap				drop trait trait_after trait_treat treat_after_trait
g				trait=isforeign_controlled==1
g				treat_after_trait=treat_after*trait
g				trait_after=trait*after
g				trait_treat=trait*treat
reg 			logdelT i.year treat trait treat_after trait_after trait_treat treat_after_trait, cluster(regno)
matrix			table[`i',`j']=_b[treat_after]
matrix			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+4,`j']=_b[treat_after_trait]
matrix			table[`i'+5,`j']=_se[treat_after_trait]
matrix			table[`i'+16,`j']=e(N)
local			j=`j'+1

/* BANK */

local			i=1
cap				drop trait trait_after trait_treat treat_after_trait
g				trait=bank==1
g				treat_after_trait=treat_after*trait
g				trait_after=trait*after
g				trait_treat=trait*treat
reg 			logdelT i.year treat trait treat_after trait_after trait_treat treat_after_trait, cluster(regno)
matrix			table[`i',`j']=_b[treat_after]
matrix			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+6,`j']=_b[treat_after_trait]
matrix			table[`i'+7,`j']=_se[treat_after_trait]
matrix			table[`i'+16,`j']=e(N)
local			j=`j'+1

/* FOOD */

local			i=1
cap				drop trait trait_after trait_treat treat_after_trait
g 				fd1=strpos(business_group, "food")
g				trait=fd1>0
drop			fd1
g				treat_after_trait=treat_after*trait
g				trait_after=trait*after
g				trait_treat=trait*treat
reg 			logdelT i.year treat trait treat_after trait_after trait_treat treat_after_trait, cluster(regno)
matrix			table[`i',`j']=_b[treat_after]
matrix			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+8,`j']=_b[treat_after_trait]
matrix			table[`i'+9,`j']=_se[treat_after_trait]
matrix			table[`i'+16,`j']=e(N)
local			j=`j'+1

/* TEXTILE */

local			i=1
cap				drop trait trait_after trait_treat treat_after_trait
g				trait=textile==1
g				treat_after_trait=treat_after*trait
g				trait_after=trait*after
g				trait_treat=trait*treat
reg 			logdelT i.year treat trait treat_after trait_after trait_treat treat_after_trait, cluster(regno)
matrix			table[`i',`j']=_b[treat_after]
matrix			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+10,`j']=_b[treat_after_trait]
matrix			table[`i'+11,`j']=_se[treat_after_trait]
matrix			table[`i'+16,`j']=e(N)
local			j=`j'+1

/* PHARMA */

local			i=1
cap				drop trait trait_after trait_treat treat_after_trait
g 				phar1=strpos(business_group,"pharma")
g				trait=phar1>0
drop			phar1
g				treat_after_trait=treat_after*trait
g				trait_after=trait*after
g				trait_treat=trait*treat
reg 			logdelT i.year treat trait treat_after trait_after trait_treat treat_after_trait, cluster(regno)
matrix			table[`i',`j']=_b[treat_after]
matrix			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+12,`j']=_b[treat_after_trait]
matrix			table[`i'+13,`j']=_se[treat_after_trait]
matrix			table[`i'+16,`j']=e(N)
local			j=`j'+1

/* CONSTRUCTION */

local			i=1
cap				drop trait trait_after trait_treat treat_after_trait
g				trait=const==1
g				treat_after_trait=treat_after*trait
g				trait_after=trait*after
g				trait_treat=trait*treat
reg 			logdelT i.year treat trait treat_after trait_after trait_treat treat_after_trait, cluster(regno)
matrix			table[`i',`j']=_b[treat_after]
matrix			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+14,`j']=_b[treat_after_trait]
matrix			table[`i'+15,`j']=_se[treat_after_trait]
matrix			table[`i'+16,`j']=e(N)
local			j=`j'+1

/* FORMATTING THE TABLE */ 

svmat 			table
keep			tab*
drop			table9-table12
keep			if _n<=17
g				c11=""
replace			c11="treat $\times$ after" in 1
replace			c11="treat $\times$ after $\times$ public" in 3
replace			c11="treat $\times$ after $\times$ foreign owned" in 5
replace			c11="treat $\times$ after $\times$ banking" in 7
replace			c11="treat $\times$ after $\times$ food" in 9
replace			c11="treat $\times$ after $\times$ textile" in 11
replace			c11="treat $\times$ after $\times$ pharma" in 13
replace			c11="treat $\times$ after $\times$ construction" in 15
replace			c11="Observations" in 17
forvalues 		c=1/8 {
g				c`c'=string(table`c',"%9.3f")
}
foreach			r in 2 4 6 8 10 12 14 16 {
forvalues		c=1/8 {
replace			c`c'="("+string(table`c',"%9.3f")+")" in `r'
}
}
forvalues		c=1/8 {
replace			c`c'=string(table`c',"%15.0fc") in 17
}
forvalues		r=3/16 {
replace			c1="" in `r'
}
forvalues		r=5/16 {
replace			c2="" in `r'
}
foreach			r in 3 4 7 8 9 10 11 12 13 14 15 16 {
replace			c3="" in `r'
}
foreach 		r in 3 4 5 6 9 10 11 12 13 14 15 16 {
replace			c4="" in `r'
}
foreach 		r in 3 4 5 6 7 8 11 12 13 14 15 16 {
replace			c5="" in `r'
}
foreach 		r in 3 4 5 6 7 8 9 10 13 14 15 16 {
replace			c6="" in `r'
}
foreach 		r in 3 4 5 6 7 8 9 10 11 12 15 16 {
replace			c7="" in `r'
}
foreach 		r in 3 4 5 6 7 8 9 10 11 12 13 14 {
replace			c8="" in `r'
}
forvalues		s=1/15 {
g				s`s'="&"
}
g				l="\\"
foreach			r in 2 4 6 8 10 12 14 16 17 {
replace			l="\\\\" in `r'
}
order			c11 s1 c1 s2 c2 s3 c3 s4 c4 s5 c5 s6 c6 s7 c7 s8 c8 l
browse			c11 s1 c1 s2 c2 s3 c3 s4 c4 s5 c5 s6 c6 s7 c7 s8 c8 l




